<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('修改福利类型')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>

</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-welfareType-edit" th:object="${welfareType}" AUTOCOMPLETE="OFF">
        <input id="id" name="id" type="hidden" th:field="*{id}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">代码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="code" id="code" th:field="*{code}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="title" id="title" th:field="*{title}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">薪资城市：</label>
            <div class="col-sm-8">
                <select id="xType" name="xType" class="form-control" th:with="type=${@dict.getType('CCD_BTType')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}" th:field="*{xType}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" th:field="*{remark}" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script type="text/javascript">
    var prefix = ctx + "welfare/region/welfareType";

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }

    function edit() {
        if ($.validate.form()) {
            var data = $("#form-welfareType-edit").serializeArray();
            var code = $("input[name='code']").val();
            var title = $("input[name='title']").val();
            var xType = $("#xType").val();
            var xorder = $("#xorder").val();
            var remark = $("#remark").val();

            data.push({"id": "code", "value": code});
            data.push({"id": "title", "value": title});
            data.push({"id": "xType", "value": xType});
            data.push({"id": "xorder", "value": xorder});
            data.push({"id": "remark", "value": remark});
            $.operate.save(prefix + "/edit", data);
        }
    }
</script>
</body>
</html>